package de.justphil.tcg.tcgserver.websockets.messages;

import net.jcip.annotations.Immutable;

import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;

//omit 'null' values when serializing to json
@Immutable
@JsonSerialize(include = Inclusion.NON_NULL)
public class TCGJoinFragment {
	@JsonProperty
	@JsonSerialize(include = Inclusion.NON_DEFAULT)
	private final long gameId;
	
	@JsonProperty
	@JsonSerialize(include = Inclusion.NON_DEFAULT)
	private final long playerId;
	
	@JsonProperty
	private final String otp;
	
	@JsonProperty
	@JsonSerialize(include = Inclusion.NON_DEFAULT)
	private final int code;
	
	public TCGJoinFragment() {
		this.gameId = 0;
		this.playerId = 0;
		this.otp = null;
		this.code = 0;
	}
	
	public TCGJoinFragment(int code) {
		this.gameId		= 0;
		this.playerId	= 0;
		this.otp		= null;
		this.code		= code;
	}
	
	public TCGJoinFragment(long gameId, long playerId, String otp) {
		this.gameId = gameId;
		this.playerId = playerId;
		this.otp = otp;
		this.code = 0;
	}

	public long getGameId() {
		return gameId;
	}

	public long getPlayerId() {
		return playerId;
	}
	
	public String getOtp() {
		return otp;
	}

	public int getCode() {
		return code;
	}
}
